<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en" class="app">
<head>
  <meta charset="utf-8" />
  <title>登录</title>
  <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/js/jPlayer/jplayer.flat.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/animate.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font-awesome.min.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/simple-line-icons.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css" type="text/css" />
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/app.css" type="text/css" />
  <!--[if lt IE 9]>
  <script src="${pageContext.request.contextPath}/js/ie/html5shiv.js"></script>
  <script src="${pageContext.request.contextPath}/js/ie/respond.min.js"></script>
  <script src="${pageContext.request.contextPath}/js/ie/excanvas.js"></script>
  <![endif]-->
  <style>
    .layui-layer-content{
      color:black
    }
  </style>
</head>
<body class="bg-info dker">
<section id="content" class="m-t-lg wrapper-md animated fadeInUp">
  <div class="container aside-xl">
    <div class="navbar-brand block">
      <span class="h1 font-bold">账号</span>
    </div>
    <section class="m-b-lg">
      <header class="wrapper text-center">
        <strong>登录发现更多</strong>
      </header>
      <div>
        <div class="form-group">
          <input type="text" id="name" placeholder="Name" class="form-control rounded input-lg text-center no-border">
        </div>
        <div class="form-group">
          <input type="password" id="pwd" placeholder="Password" class="form-control rounded input-lg text-center no-border">
        </div>
        <button  id="login" type="submit" class="btn btn-lg btn-warning lt b-white b-2x btn-block btn-rounded"><i class="icon-arrow-right pull-right"></i><span class="m-r-n-lg">登陆</span></button>
        <div class="text-center m-t m-b" >
          <a href="${pageContext.request.contextPath}/page/util/password.jsp"><small>忘记密码?</small></a>
        </div>
        <div class="line line-dashed"></div>
        <p class="text-muted text-center"><small>没有账号?</small></p>

        <a href="${pageContext.request.contextPath}/page/util/register.jsp" class="btn btn-lg btn-info btn-block btn-rounded">注册账号</a>

      </div>
    </section>
  </div>
</section>
<!-- footer -->
<footer id="footer">
  <div class="text-center padder">
    <p>
      <small>浙江工业大学 | 教育科学与技术学院<br>ZJUT-2017</small>
    </p>
  </div>
</footer>
<!-- / footer -->
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
<!-- App -->
<script src="${pageContext.request.contextPath}/js/app.js"></script>
<script src="${pageContext.request.contextPath}/layer/layer.js"></script>
<script src="${pageContext.request.contextPath}/js/slimscroll/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/js/app.plugin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jPlayer/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jPlayer/add-on/jplayer.playlist.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jPlayer/demo.js"></script>

<script>
  /*登录*/


  $("#login").click(function () {
    var name=$("#name").val();
    var pwd=$("#pwd").val();
    if (name=="" || pwd==""){
      layer.msg('请填写用户名或者密码！', {time: 3000, icon:5});
      return false;
    }
    var regInfo={
      username:name,
      pwd:pwd
    };
    $.ajax({
      contentType:"application/json",
      url:getRootPath()+"/user/login",
      type:"post",
      dataType:"json",
      data:JSON.stringify(regInfo),
      success:function (data) {
        if (data.res==0){
          layer.msg(data.msg, {time: 3000, icon:2});
        }else {
          var url="${pageContext.request.contextPath}/page/indexpage.jsp";
          window.parent.location.href=url;
        }

      },
      error:function (error) {
        layer.msg('连接失败！', {time: 3000, icon:5});
      }

    });
  });



  function getRootPath() {
    var curWwwPath = window.document.location.href;
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    var localhostPaht = curWwwPath.substring(0, pos);
    var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    return (localhostPaht + projectName);
  }

</script>
</body>
</html>